<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Menu
 *
 * @author dro
 */

namespace Gairal\CoreBundle\Entity;

class Menu {

    private $title;
    private $mainRoute;
    private $routes;
    private $isActive;

    /**
     * Constructor
     */
    public function __construct($currRoute, $title, $mainRoute, $routes = null) {
        $this->title = $title;
        $this->mainRoute = $mainRoute;
        $this->routes = $routes;
        $this->determineIsActive($currRoute);
    }

    /**
     * Get title
     *
     * @return string 
     */
    public function getTitle() {
        return $this->title;
    }

    /**
     * Get mainRoute
     *
     * @return string
     */
    public function getMainRoute() {
        return $this->mainRoute;
    }

    /**
     * Get routes
     *
     * @return array 
     */
    public function getRoutes() {
        return $this->routes;
    }

    /**
     * Get isActive
     *
     * @return bool 
     */
    public function getIsActive() {
        return $this->isActive;
    }

    private function determineIsActive($currRoute) {
        if ($this->routes != null) {
            for ($i = 0; $i < count($this->routes); $i++) {
                if ($currRoute == $this->routes[$i]){
                    $this->isActive = true;
                    break;
                }
            }
        }
        else {
            if ($currRoute == $this->mainRoute)
                $this->isActive = true;
        }
    }

}

?>
